1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.smartcrawler.retriever;
28 import java.util.Hashtable;
29 import org.smartcrawler.common.Link;
30
31
32 /***
33 *
34 *
35 * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
36 * @version <tt>$Revision: 1.4 $</tt>
37 */
38 public class HttpCall implements Call {
39
40 private Hashtable params = new Hashtable();
41 private Link link;
42 private String userAgent;
43 private int method;
44 private Content content;
45
46 private static String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.5) Gecko/20041110 Firefox/1.0";
47
48 /***
49 * Creates a new instance of HttpCall
50 * @param link
51 */
52 public HttpCall(Link link) {
53 this.link = link;
54 setUserAgent(DEFAULT_USER_AGENT);
55 setMethod(GET);
56 }
57
58 /***
59 *
60 * @param link
61 * @param method
62 */
63 public HttpCall(Link link, int method) {
64 this.link = link;
65 setUserAgent(DEFAULT_USER_AGENT);
66 setMethod(method);
67 }
68
69 /***
70 *
71 * @return
72 */
73 public Link getLink() {
74 return this.link;
75 }
76
77 /***
78 *
79 * @param key
80 * @param value
81 */
82 public void addParameter(String key, String value) {
83 params.put(key, value);
84 }
85
86 /***
87 *
88 * @return
89 */
90 public String getUserAgent() {
91 return userAgent;
92 }
93
94 /***
95 *
96 * @param userAgent
97 */
98 public void setUserAgent(String userAgent) {
99 this.userAgent = userAgent;
100 }
101
102 /***
103 *
104 * @return
105 */
106 public int getMethod() {
107 return method;
108 }
109
110 /***
111 *
112 * @param method
113 */
114 public void setMethod(int method) {
115 this.method = method;
116 }
117
118 /***
119 *
120 * @return
121 */
122 public Content getContent() {
123 return content;
124 }
125
126 /***
127 *
128 * @param content
129 */
130 public void setContent(Content content) {
131 this.content = content;
132 }
133
134
135 }